/**
 * Created by Administrator on 2018/11/19.
 */
function listStamp($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams, $q, fileListService, backlogPersonList) {
    $$scope = $scope;
    $CertusFormAjax = CertusFormAjax;
    $CertusJsonAjax = CertusJsonAjax;
    $fileListService = fileListService;
    $backlogPersonList = backlogPersonList;

    $CertusJsonAjax.dataInit("signet/signetPage", null, stamplistColumns, 'stamplistContainer', 'stamplistToolBarContainer');

    $CertusJsonAjax.dataInit("signet/signetStepPage", null, stampColumns, 'stampContainer', 'stampToolBarContainer');

    $CertusJsonAjax.dataInit("signet/signetStepPageAll", null, stampColumns, 'stampContainerMain', 'stampToolBarContainerMain');

}

function addStamp($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams, $q, fileListService, backlogPersonList) {
    $$scope = $scope;

    $CertusFormAjax = CertusFormAjax;
    $CertusJsonAjax = CertusJsonAjax;
    $fileListService = fileListService;
    $backlogPersonList = backlogPersonList;


    //使用方式 select
    $$scope.usageModeSelect = [
        {
            name: "借出", code: "loan"
        },
        {
            name: "使用", code: "use"
        }
    ]

    $$scope.affiliationSelect = [{
        name: "赛特斯(南京)",
        code: "STSNJ"
    },
        {
            name: "赛特斯(北京)",
            code: "STSBJ"
        },
        {
            name: "赛特斯(广州)",
            code: "STSGD"
        },
        {
            name: "赛特斯(上海)",
            code: "STSSH"
        },
        {
            name: "浩方(上海)",
            code: "HFSH"
        },
        {
            name: "浩方(南京)",
            code: "HFNJ"
        }
    ]

    $$scope.locationChange = function () {
        //查询印章 select
        $CertusFormAjax.ajax("signet/signetEntityList", {location: $$scope.signet.locationCode}, function (res) {
            $$scope.signetCodeSelect = res.data;
        })
    }


    $$scope.signetSubmit = function () {
        //页面保存 发起 印章申请流程。
        if (certusValidateNotnull()) {
            $CertusFormAjax.ajax("signet/currentUserId", {}, function (res) {
                $$scope.file = {
                    classCategoriesCode: 'aa',
                    fileClass: 'aa',
                    fileDescriptor: $$scope.signet.application,
                    fileName: $$scope.signet.fileName,
                    fileManager: res.data,
                    uploaderLeader: res.data,
                    classFictionCode: 'secret'
                }

                fileUpload1($$scope, function (res) {
                    $$scope.signet.fileId = res.data;
                    //填入 用章名称
                    for (var i in $$scope.signetCodeSelect) {
                        if ($$scope.signetCodeSelect[i].signetCode == $$scope.signet.signetCode) {
                            $$scope.signet.signetName = $$scope.signetCodeSelect[i].signetName;
                        }
                    }
                    //启动 流程
                    $CertusJsonAjax.ajax("signet/startSignetStep", $$scope.signet, function (res) {
                        if (res.data == "success") {
                            findBacklogPersonHead($CertusFormAjax, "YZLC");
                            history.back();
                        }
                    })
                }, null);
            })
        }
    }

}

function selStamp($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams, $q, fileListService, backlogPersonList) {
    $$scope = $scope;
    $CertusFormAjax = CertusFormAjax;
    $CertusJsonAjax = CertusJsonAjax;
    $fileListService = fileListService;
    $backlogPersonList = backlogPersonList;

    /**
     * Created by Administrator on 2018/11/20.
     */
//查询数据

    $CertusFormAjax.ajax("signet/signetStepBySignetStepCode", {
        "signetStepCode": $routeParams.signetStepCode
    }, function (res) {
        $$scope.signet = res.data.signet;
        $$scope.processs = res.data.processs;
        //查询印章 select
        $CertusFormAjax.ajax("signet/signetEntityList", {location: $$scope.signet.locationCode}, function (res) {

            $$scope.signetCodeSelect = res.data;
        })
    })
//初始化 select
//使用方式 select
    $$scope.usageModeSelect = [
        {
            name: "借出", code: "loan"
        },
        {
            name: "使用", code: "use"
        }
    ]

//查询印章 select
    $CertusJsonAjax.ajax("signet/signetEntityList", null, function (res) {
        $$scope.signetCodeSelect = res.data;
    })

//下载文件
    $$scope.yzlcDownload = function () {
        $CertusFormAjax.download("downloadFile", "fileId=" + $$scope.signet.fileId);
    }


    $$scope.getsssbbb = function (bb) {
        if (bb == "starting") {
            return "正在进行中";
        } else if (bb == "denied") {
            return "否决";
        } else if (bb == "sentback") {
            return "被退";
        } else if (bb == "others") {
            return "关闭";
        } else if(bb == "completed"){
            return "完成";    }else if(bb == "terminated"){        return "终结";    }    else if(bb == "cancelled"){        return "通过";}
        return "待办";
    }
}